//
// Created by hjie on 23-6-3.
//
#include "write_buffer.h"

void TestWriteBuffer()
{
    WriteBuffer buffer;

    std::string content = "this is a test line.";
    buffer.Write((const uint8_t*)content.c_str(), content.size());
    if (buffer.Length())
    {
        printf("content : %s and length : %ld\n", buffer.Data(), buffer.Length());
    }
    buffer.RemoveSize(buffer.Length());

    buffer.Write((uint8_t)'A');
    if (buffer.Length())
    {
        printf("write uint8 : %s and length : %ld\n", buffer.Data(), buffer.Length());
    }
    buffer.RemoveSize(buffer.Length());

    buffer.Write((uint16_t)6379);
    if (buffer.Length())
    {
        uint16_t tmp = 0;
        memcpy(&tmp, buffer.Data(), 2);
        printf("write uint16 : %d and length : %ld\n", tmp, buffer.Length());
    }
    buffer.RemoveSize(buffer.Length());
}

int main(int argc, char * argv[])
{
    TestWriteBuffer();
    return EXIT_SUCCESS;
}